package com.sc.springboot.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sc.springboot.pojo.Food;
import com.sc.springboot.pojo.Goods;
import com.sc.springboot.service.IFoodService;
import com.sc.springboot.util.ResponseMsg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author romeo
 * @since 2025-09-23 08:14:05
 */
@RestController
@RequestMapping("/food")
public class FoodController {
    @Autowired
   private IFoodService foodService;

    @RequestMapping("/getByKeyWord")
    public ResponseMsg getByKeyWord(@RequestParam String keyWord) {

        List<Food> list = foodService.list(new QueryWrapper<Food>().like("food_name", keyWord));
        if (list==null) {
            return ResponseMsg.getInstance(ResponseMsg.FAIL, "没有更多食品了");
        }
        return ResponseMsg.getInstance(ResponseMsg.SUCCESS, list);
    }

}
